package xyz.coolcsm.security.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.coolcsm.security.entity.SysRequestPath;
import xyz.coolcsm.security.mapper.SysRequestPathMapper;
import xyz.coolcsm.security.service.SysRequestPathService;

import java.util.List;
/**
 * @author 什锦
 * @since 2021-06-1
 */
@Service
public class SysRequestPathServiceImpl implements SysRequestPathService {

    @Autowired
    SysRequestPathMapper sysRequestPathMapper;

    @Override
    public SysRequestPath queryById(Integer id) {
        return sysRequestPathMapper.selectById(id);
    }

    @Override
    public List<SysRequestPath> queryAllByLimit(int offset, int limit) {
        Page<SysRequestPath> page = new Page<>(offset, limit);
        Page<SysRequestPath> result = sysRequestPathMapper.selectPage(page, null);
        return result.getRecords();
    }

    @Override
    public SysRequestPath insert(SysRequestPath sysRequestPath) {
        sysRequestPathMapper.insert(sysRequestPath);
        return sysRequestPath;
    }

    @Override
    public SysRequestPath update(SysRequestPath sysRequestPath) {
        sysRequestPathMapper.updateById(sysRequestPath);
        return sysRequestPath;
    }

    @Override
    public boolean deleteById(Integer id) {
        return sysRequestPathMapper.deleteById(id)>0;
    }
}
